package sys;

import java.util.*;

import sys.fsm.*;
import sys.transport.*;
import sys.logic.*;
import sys.message.*;
import sys.timer.TimerClient;
import sys.database.*;

public class Main
{
    Timer timer;

    public static void main(String args[])
    {
        if (args.length > 0)
        {
            if (args[0].compareTo("system") == 0)
            {
                System.out.println("Starting up a system...");
            }
            else if (args[0].compareTo("LogicTests") == 0)
            {
                System.out.println("Runnig logic tests");
                sys.tests.logic.RunTests.run();
            }
        }
        else
        {
            /*DBWrapper dbw = new DBWrapper("localhost", "systema", "systema", "systema");*/
            //dbw.connect();
            ////dbw.test();
        //dbw.insert("Request", "ID, PayingSystem_Address, User_Name, Quantity", 0 + "," + "'ps_1'" + "," +  "'user_1'" + "," + 10);
            /*dbw.disconnect();*/

            /*System.out.println("Creating system c database");*/
            //SyscDatabase.dropTables("localhost", "systemc", "systemc", "systemc");
            /*SyscDatabase.createTables("localhost", "systemc", "systemc", "systemc");*/
            try
            {
                JSONMessage mes = new JSONMessage("xelax-a1@dev.iu7.bmstu.ru", "xelax-c1@dev.iu7.bmstu.ru", "shaman");
                
                mes.put("Type", "shaman");
                new MessageSenderSMTP("dev.iu7.bmstu.ru", "10025").send(mes);
           }
            catch(Exception e) {System.out.println(e.getMessage());}

            
            RequestManager rm = new RequestManager("configS");
            rm.start();

        }
    }

/*    public void testTimer()*/
    //{
        //timer = new Timer();
        //timer.schedule(new ToDo(), 1000, 2000); 
        //System.out.println("Waiting...");
    //}

    //class ToDo extends TimerTask
    //{
        //public void run()
        //{
            //System.out.println("From timer");
            ////timer.cancel();    
        //}
    /*}*/
}

/*class TimerClientClass implements TimerClient*/
//{
    //public void timeout(Object marker)
    //{
        //System.out.println(marker.toString());
    //}
//}

//class T implements MessageCheckerClient
//{
    //public void newMessages(Vector<UniMessage> messages)
    //{
        //for (UniMessage m : messages)
        //{
            //System.out.println("In message checker client");
            //System.out.println("FROM: " + m.getFrom() + ", TO: " + m.getTo() + ", BODY: " + m.getBody());
        //}
    //}
/*}*/
